package cn.javabb.core.service.biz;

import cn.javabb.core.base.BaseService;
import cn.javabb.core.entity.biz.NavDO;
import cn.javabb.core.model.StatusEnum;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 菜单管理
 * @Author QINB imqinbao@163.com
 * @CreateDate 2018/11/23/023 16:38
 * @Since V1.0
 */
@Service
public class NavService extends BaseService<NavDO> {
    /**
     * 修改状态
     * @param id
     * @param state
     * @return
     */
    public boolean updateState(Integer id,Integer state){
        NavDO nav = new NavDO();
        nav.setNavId(id);
        nav.setState(state);
        return this.updateSelective(nav)>0?true:false;
    }

    /**
     * 获取导航
     * 1：网站菜单，2：top导航，3：底部导航，4：快速通道
     * @return
     */
    public List<NavDO> listNavs(int type){
        Example ex = new Example(NavDO.class);
        ex.createCriteria().andEqualTo("navType",type).andEqualTo("state", StatusEnum.NORMAL.getCode());
        ex.orderBy("orderNo").asc().orderBy("createTime").desc();
        List<NavDO> list = this.queryListByExample(ex);
        return list;
    }
}
